<!DOCTYPE html>
<html>
<head lang="zh-CN">
    <meta charset="UTF-8">
    <meta name="viewport" content=" initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <title>我的密友圈</title>
    <link href="{$Think.config.RESOURCEURL}wx_assets/css/common.css{$Think.config.RESOURCE_VER}" rel="stylesheet" type="text/css">
    <link rel="stylesheet" type="text/css" href="{$Think.config.RESOURCEURL}wx_assets/quan/quanList.css" />
    <script type="text/javascript" src="{$Think.config.RESOURCEURL}wx_assets/js/zepto.1.1.3.min.js"></script>
    <script src="{$Think.config.RESOURCEURL}wx_assets/js/util.js" type="text/javascript"></script>
    <link href="{$Think.config.RESOURCEURL}wx_assets/css/common.css{$Think.config.RESOURCE_VER}" rel="stylesheet" type="text/css">
    <link rel="stylesheet" type="text/css" href="{$Think.config.RESOURCEURL}wx_assets/quan/quanList.css{$Think.config.RESOURCE_VER}" />
    <script type="text/javascript" src="{$Think.config.RESOURCEURL}wx_assets/js/zepto.1.1.3.min.js{$Think.config.RESOURCE_VER}"></script>
    <script src="{$Think.config.RESOURCEURL}wx_assets/js/util.js{$Think.config.RESOURCE_VER}" type="text/javascript"></script>
    <script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script src="{$Think.config.RESOURCEURL}wx_assets/js/wx_share.js{$Think.config.RESOURCE_VER}" type="text/javascript"></script>
</head>
<body>
     <div class="quan-box" id="quanBox">
       
    </div>
</body>
<script type="text/html" id="quanTpl">
    <%if(list){
        for(var i=0;i<list.length;i++){
            var item=list[i];
            if(item.activeTime){
                item.activeTime=item.activeTime.replace(/-/g,"/");
            }
        %>
        <dl class="quan" onclick="quanList.goHome('<%=item.id%>')">
           <dt>
           </dt>
           <dd>
                <div class="logo">
                    <img src="<%=item.logo%>" onload="$.util.imgZoom(this,55,55)"/>
                </div>
                <div class="name"><%=item.name%></div>
           </dd>
       </dl>
        <%}%>
    <%} else {%>
        <div class="norecord">您还没有加入任何密友圈</div>
    <%}%>
</script>
<script type="text/javascript">
    var baseUrl = '{$Think.config.SERVER_HOST}';
    var p=$.util.getParamAsObject();
    var quanList={
        pageSize:10,
        page:0,
        init:function(){
            var me=this;
            this._initEvent();
            $.util.pageLoading.show();
            me._loadList(me.page,function(){
                $.util.pageLoading.hide();
            });
        },
        goHome:function(qId){
            if(p&& p.community){
                location.href='{$Think.config.SERVER_HOST}call.html?customerId={$customerId}&userName={$userName}&module=community&method=index&params=%7B"qid"%3A"'+qId+'"%7D';
            }else{
                location.href='{$Think.config.SERVER_HOST}call.html?customerId={$customerId}&userName={$userName}&module=quan&method=index&params=%7B"qId"%3A"'+qId+'"%7D';
            }
        },
        toDetail:function(customerId,id){
            var params={
                "id":id
            }
            params=encodeURIComponent(JSON.stringify(params));
            location.href= 'call.html?customerId='+customerId+'&module=product&method=getProduct&params='+params;
        },
        _initEvent:function(){
            var me=this;
            $.util.initDataLoading({
                me:quanList,
                lastChildren:function(){
                    return $("#quanBox .quan:last");
                },
                page:function(){
                    return quanList.page;
                },
                pageCount:function(){
                    return quanList.pageCount;
                }
            });
        },
        _renderList:function(data,page,callback){
           var me=this;
           if(data){
                var html=template("quanTpl", data),
                    container=$("#quanBox");
                container.append(html);
                me.page=page;
                me.pageCount=data.pageCount;
                callback && callback();
           }   
        },
        _loadList:function(page,callback){
            var me=this;
            $.req.get("call.json?module=quan&customerId={$customerId}&method=getQuanList",{
                userName:"{$userName}",
                params:{
                    "start":page,
                    "limit":me.pageSize
                }
            },function(data){
                if(data){
                    me._renderList(data,page,callback);
                }
            });
        }
    }
    quanList.init();
     wx_share.init({
        "pkg":{
            "appId": '{$pkg.appId}',
            "timestamp": {$pkg.timestamp},
            "nonceStr": '{$pkg.nonceStr}',
            "signature": '{$pkg.signature}'
        },
        hide:1
    });
</script>
</html>